jQuery(document).ready(function(){
    /**
     * add new input file
     */
    jQuery('.add-file').click(function(){
	var moreInput = '<div class="wrap-ext-input"><input type="file" name="image[]"/>';
	moreInput += '<a title="delete" href="javascript:void(0)" class="button button-primary button-large remove-ext-input-img">X</a></div>';
	jQuery(this).before(moreInput);
    });
    /**
     * remove input file
     */
    jQuery(document).on('click','.remove-ext-input-img', function(){
	jQuery(this).parent().remove();
    });
    /*
     * delete image when admin update flight/deal 
     */
    jQuery('.delete-image').click(function(){
	
	var obSelf = jQuery(this);
	var imageName = jQuery(this).attr('image-name');
	
	jQuery.post(templateUrl + '/ajax/admin/delete-file.php', {imageName: imageName}, function(data){
	    obSelf.parent().remove();	    
	});
    });    
    
});
